/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package at.htlkaindorf.sportartikel.webshop.view;

import at.htlkaindorf.sportartikel.webshop.session.SessionBean;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author Stefan
 */
@ManagedBean(name = "loginBean")
@ViewScoped
public class LoginBean {

    @ManagedProperty(value = "#{sessionBean}")
    private SessionBean sessionBean;

    private String username;
    private String password;
    private String country;

    public String login() {
        if (checkPassword()) {
            sessionBean.setCountry(country);
            sessionBean.setUsername(username);
            return "webshop_home";
        }
        return "login";
    }

    private boolean checkPassword() {
        return username.equals("admin")&&password.equals("admin");
    }

    public SessionBean getSessionBean() {
        return sessionBean;
    }

    public void setSessionBean(SessionBean sessionBean) {
        this.sessionBean = sessionBean;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }
}
